package com.xianyun.smartpicturebackend.common;

import com.xianyun.smartpicturebackend.exception.ErrorCode;
import lombok.Data;

import java.io.Serializable;

/** 通用响应类
 * @author xianYun
 * @version 1.0
 **/
@Data
public class BaseResponse<T> implements Serializable {


    private int code;//响应状态码

    private T data;//响应数据

    private String message;//响应信息

    public BaseResponse(int code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public BaseResponse(int code, T data) {
        this(code, data, "");
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage());
    }
}
